package cn.wolfcode.p2p.base.domain;

import cn.wolfcode.p2p.util.BitStatesUtils;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class UserInfo extends BaseDomain {
       private  Integer Version =0 ;//版本号，用作乐观锁
       private  Long bitState=0L;//用户状态值
       private  String realName;//用户实名值（冗余数据）
       private  String idNumber;//用户身份证号（冗余数据）
       private  String phoneNumber;//用户电话
       private String email; //邮件
       private  SystemDictionaryItem incomeGrade;//收入
       private  SystemDictionaryItem marriage;//婚姻情况
       private  SystemDictionaryItem kidCount;//子女情况
       private  SystemDictionaryItem educationBackground;//学历
       private  SystemDictionaryItem houseCondition;//住房条件

       private Long realAuthId;//身份认证对应的Id
       private Long videoAuthId;//视频认证对应的Id
       private Long bankInfoId;//银行卡的Id

       //新增三个判断认证情况的方法

       public boolean hasBasicInfo(){
              return (BitStatesUtils.hasState(bitState,BitStatesUtils.OP_BASIC_INFO));
       }
       public boolean hasRealAuth(){
              return BitStatesUtils.hasState(bitState,BitStatesUtils.OP_REAL_AUTH);
       }
       public boolean hasVedioAuth(){
              return BitStatesUtils.hasState(bitState,BitStatesUtils.OP_VEDIO_AUTH);
       }
       public boolean hasBorrow(){
              return BitStatesUtils.hasState(bitState,BitStatesUtils.HAS_BIDREQUEST_IN_PROCESS);
       }
       public boolean hasPassWord(){
              return BitStatesUtils.hasState(bitState,BitStatesUtils.OP_HOSTING_PASSWORD);
       }
       public boolean canBorrow(){
              return (hasBasicInfo()&&hasRealAuth()&&hasVedioAuth());
       }

       public void addBitState(Long tempState) {
              long tempState1 = BitStatesUtils.addState(bitState,tempState );
              this.setBitState(tempState1);
       }

       public void removeBitState(Long state) {
              long l = BitStatesUtils.removeState(bitState, state);
              this.bitState=l;
       }
}
